package org.rency.crawler.domain;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 描述: 抓取扩展信息<br>
 * 最近修改时间:2017/11/20 17:43<br>
 *
 * @author CaiyuRen
 * @version V1.0
 * @since 2017/11/20 17:43
 */
public class FetchExtension implements Serializable {

  /**
   * 最新抓取时间
   */
  private LocalDateTime lastedFetchTime;

  /**
   * 抓取深度
   */
  private int           fetchDepth;

  /**
   * 权重
   */
  private Double        fetchWeight;

  /**
   * 机器IP
   */
  private String        machineIP;

  /**
   * 重试次数
   */
  private int           retryTimes;

  /**
   * 最大重试次数
   */
  private int           maxRetryTimes;

  private String        remark;

  public void addRetryTimes(){
    this.retryTimes++;
  }

  public LocalDateTime getLastedFetchTime() {
    return lastedFetchTime;
  }

  public void setLastedFetchTime(LocalDateTime lastedFetchTime) {
    this.lastedFetchTime = lastedFetchTime;
  }

  public int getFetchDepth() {
    return fetchDepth;
  }

  public void setFetchDepth(int fetchDepth) {
    this.fetchDepth = fetchDepth;
  }

  public Double getFetchWeight() {
    return fetchWeight;
  }

  public void setFetchWeight(Double fetchWeight) {
    this.fetchWeight = fetchWeight;
  }

  public String getMachineIP() {
    return machineIP;
  }

  public void setMachineIP(String machineIP) {
    this.machineIP = machineIP;
  }

  public int getRetryTimes() {
    return retryTimes;
  }

  public void setRetryTimes(int retryTimes) {
    this.retryTimes = retryTimes;
  }

  public int getMaxRetryTimes() {
    return maxRetryTimes;
  }

  public void setMaxRetryTimes(int maxRetryTimes) {
    this.maxRetryTimes = maxRetryTimes;
  }

  public String getRemark() {
    return remark;
  }

  public void setRemark(String remark) {
    this.remark = remark;
  }

  /**
   * 构造器
   * <p>构造模式</p>
   */
  static class Builder{
    private FetchExtension extension = new FetchExtension();

    public Builder setLastedFetchTime(LocalDateTime lastedFetchTime){
      extension.setLastedFetchTime(lastedFetchTime);
      return this;
    }

    public Builder setFetchDepth(int fetchDepth){
      extension.setFetchDepth(fetchDepth);
      return this;
    }

    public Builder setFetchWeight(double fetchWeight){
      extension.setFetchWeight(fetchWeight);
      return this;
    }

    public Builder setMachineIP(String machineIP){
      extension.setMachineIP(machineIP);
      return this;
    }

    public Builder setRetryTimes(int retryTimes){
      extension.setRetryTimes(retryTimes);
      return this;
    }

    public Builder setMaxRetryTimes(int maxRetryTimes){
      extension.setMaxRetryTimes(maxRetryTimes);
      return this;
    }

    public Builder setRemark(String remark){
      extension.setRemark(remark);
      return this;
    }

    public FetchExtension build(){
      return extension;
    }
  }

}
